// ie placeholder兼容
/*
    * jQuery placeholder, fix for IE6,7,8,9
*/
var JPlaceHolder = {
    //检测
    _check : function(isAddPla){
        return 'placeholder' in document.createElement('input');
    },
    //初始化
    init : function(isAddPla){
        if(!this._check(isAddPla)){
            this.fix(isAddPla);
        }
    },
    //修复
    fix : function(isAddPla){
        if(isAddPla===0){
            $(':input[placeholder]').each(function(index, element) {
            var self = $(this), txt = self.attr('placeholder');
            self.wrap($('<div></div>').css({ zoom:'1', border:'none', background:'none', padding:'none', margin:'none',display:'inline'}));
            var pos = self.position(), h = self.outerHeight(true)+"px"/*, paddingleft = self.css('padding-left')*/;
            var holder = $('<a class="ieInput"></a>').text(txt).css({position:'absolute', left:pos.left+"2%", top:"pos.top", height:h, lineHeight:h, color:'#aaa'}).appendTo(self.parent());
            self.focusin(function(e) {
                holder.hide();
            }).focusout(function(e) {
                if(!self.val()){
                    holder.show();
                }
            });
            holder.click(function(e) {
                holder.hide();
                self.focus();
            });
        });
        }else if(isAddPla===1){
            $(".ieInput").attr("style","display:none");
        }

   
    }
};
//执行
$(function(){
    var isAddPla=0;
    JPlaceHolder.init(isAddPla);    
});